﻿
namespace ZR.Model.Models.ProductionControl
{
    /// <summary>
    /// 打包任务
    /// </summary>
    [SugarTable("cks_packaging_task")]
    [Table(Name = "cks_packaging_task")]
    public class CksPackagingTask : BaseEntity
    {
        /// <summary>
        /// Id 
        /// </summary>
        [SugarColumn(IsPrimaryKey = true, IsIdentity = true)]
        [Column(IsPrimary = true, IsIdentity = true)]
        public long Id { get; set; }

        /// <summary>
        /// 任务编号 
        /// </summary>
        public string TaskNo { get; set; }

        /// <summary>
        /// 流转容器编号 
        /// </summary>
        public string ContainerNo { get; set; }

        /// <summary>
        /// 面单号 
        /// </summary>
        public string WaybillNo { get; set; }

        /// <summary>
        /// 订单号 
        /// </summary>
        public string OrderNo { get; set; }

        /// <summary>
        /// 包裹号 
        /// </summary>
        public string PackageNo { get; set; }


        public DateTime? InTime {  get; set; }

        public DateTime? OutTime { get; set; }
        /// <summary>
        /// 最后上传时间
        /// </summary>
        public DateTime? UploadTime { get; set; }
        public bool CanUpload {  get; set; }
        /// <summary>
        /// 上传状态 0 未开始 1成功 2失败
        /// </summary>
        public int UploadStatus {  get; set; }
        /// <summary>
        /// 时长:秒
        /// </summary>
        public int Duration {  get; set; }

        /// <summary>
        /// 生产模式 1正式 2调试
        /// </summary>
        public int ProductMode { get; set; }

        [Column(MapType = typeof(int))]
        public TaskStatusType TaskStatus { get; set; }

        [Column(IsIgnore =true)]
        [SugarColumn(IsIgnore =true)]
        public string TaskStatusText { get { return TaskStatus.ToString(); } }

        /// <summary>
        /// 当前执行步骤号
        /// </summary>
        public int StepNo { get; set; }

        /// <summary>
        /// 包裹位置
        /// </summary>
        public string Position {  get; set; } = string.Empty;
        /// <summary>
        /// 禁用(无效)状态 
        /// </summary>
        public bool Nullity { get; set; }

        /// <summary>
        /// 创建时间 
        /// </summary>
        public DateTime CreatedTime { get; set; } = DateTime.Now;


        //public bool IsUnBind
        //{
        //    get
        //    {
        //        var state = (int)this.TaskStatus;
        //        return state >=3 && state <= 20;
        //    }
        //}

    
        

    }

    public enum TaskStatusType:int
    {
        接收订单信息 = 0,
        尺寸测量完成 = 1,
        抓取校验成功 = 2,
        解除容器绑定 = 3,
        打印面单完成 = 4,
        检查面单OK = 5,
        
        上传业务系统成功 = 20,
        抓取校验失败 = 21,
        检查面单NG = 22,
        上传业务系统失败=23,

        重新绑定箱号 = 101,
        包裹重新包装 = 102,
        解除容器绑定_手动 = 103,

    }


}